#!/usr/bin/env ts-node
function createPrefix (n: number):string{
  return '---'.repeat(n)
}

class Person{
  public children: Person[] = [];
  constructor(public name: string){}
  addChild(child: Person):void{
    this.children.push(child)
  }
  introduceFamily(n?:number):void{
    n = n || 1;
    console.log(`${createPrefix(n-1)}${this.name}`)
    this.children.forEach(child=>{
      child.introduceFamily(n+1)
    })
  }
}

let grandPa = new Person('commit-1')
let child1 = new Person('commit-1-1')
let child2 = new Person("commit-1-2")
let person11 = new Person("commit-1-1-1")
let person12 = new Person("commit-1-1-2")
let person21 = new Person("commit-1-2-1")
let person22 = new Person("commit-1-2-2")
grandPa.addChild(child1)
grandPa.addChild(child2)
child1.addChild(person11)
child1.addChild(person12)
child2.addChild(person21)
child2.addChild(person22)
grandPa.introduceFamily()



